<!DOCTYPE html>
<html>
  <head>
    <title>Performance Test</title>
    <script src="config.js"></script>
    <script>
      var saveTraceRegEx = /[?&]wtf=?([^&]*)/;
      var saveTrace =
          saveTraceRegEx.exec(testConfig) || saveTraceRegEx.exec(window.location.search);

      var needsTraceStart = false;
      if (saveTrace && !window.wtf) {
        needsTraceStart = true;
        var wtfUrl = "https://tracing-framework.appspot.com/CURRENT/wtf_trace_web_js_compiled.js";
        if (saveTrace[1]) wtfUrl = saveTrace[1];
        document.write('<' + 'script type="text/javascript" src="' + wtfUrl + '"><' + '/script>');
      }
    </script>
    <style>
      body #wtf-failed {display: none}
      body.wtf-failed {background: red}
      body.wtf-failed #wtf-failed {display: block; color: white}
    </style>
  </head>
  <body>
    <script src="tracked.js"></script>
    <h1 id="wtf-failed">Failed to load tracing framework.</h1>
    <script>
      if (needsTraceStart && !window.wtf) {
        document.body.className += "wtf-failed";
      } else {
        var tracker = new Tracker();
        // Upload WTF traces to the metric tracker.
        if (saveTrace) {
          tracker.enableTracing(needsTraceStart, 'http-rel:/savetrace');
        }
        tracker.run();
      }
    </script>
  </body>
</html>
